package chapter17;

import java.util.Timer;
import java.util.TimerTask;
import java.util.concurrent.TimeUnit;

/**
 * @author lzy
 * @version v1.0
 * Create DateTime: 2019/2/24 15:19
 */
public class BasicTimer {
    public static void main(String[] args) throws InterruptedException {
        Timer timer = new Timer();
        timer.schedule(new DelayTask(), 1000);
        TimeUnit.SECONDS.sleep(3);
        timer.cancel();
    }

    static class DelayTask extends TimerTask {

        @Override
        public void run() {
            System.out.println("delay task");
        }
    }
}
